package dimensional.traveler.server.services.servlets;

import java.util.ArrayList;
import java.util.List;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.google.inject.Inject;

import dimensional.traveler.client.services.CharacterClassService;
import dimensional.traveler.server.model.CharacterClass;
import dimensional.traveler.server.persistence.CharacterClassRepository;
import dimensional.traveler.shared.model.CharacterClassDTO;

public class CharacterClassServiceImpl extends RemoteServiceServlet implements CharacterClassService {
	
	private static final long serialVersionUID = 7789862223464416127L;
	
	@Inject
	private CharacterClassRepository repository;
	
	@Override
	public List<CharacterClassDTO> getCharacterClasses() {
		List<CharacterClass> characterClasses = repository.getCharacterClasses();
		List<CharacterClassDTO> dtos = new ArrayList<>(characterClasses.size());
		
		for (CharacterClass characterClass : characterClasses){
			dtos.add(characterClass.toCharacterClassDTO());
		}
		
		return dtos;
	}
	
}
